//
//  STButton.m
//  赛拓
//
//  Created by 王磊 on 7/31/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STButton.h"
@interface STButton()
@property (nonatomic ,strong) UIImageView *iconImageView;
@end
@implementation STButton

+ (instancetype)getInstance {
    return [[self alloc]init];
}

- (instancetype)init {
    if (self = [super init]) {
        
        [self commitInit];
    }
    return self;
}
- (void)setUrlString:(NSString *)urlString {
    _urlString = urlString;
    
    [self.iconImageView set_BGBannerImageViewWithString:urlString];
}
- (void)commitInit {
    
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    
    UIImageView *imageView = [[UIImageView alloc]init];
    
    self.iconImageView = imageView;
    
    [self addSubview:imageView];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    // 调整图片
    CGFloat size = 80 * ST_RATE;
    
    self.iconImageView.k_x = ( self.k_width - size ) / 2;
    self.iconImageView.k_y = 0;
    self.iconImageView.k_width = size;
    self.iconImageView.k_height = size;
    
    // 调整文字
    self.titleLabel.k_x = 0;
    self.titleLabel.k_y = size + 20 * ST_RATE;
    self.titleLabel.k_width = self.k_width;
    self.titleLabel.k_height = self.k_height - self.k_width;
    
}

@end
